﻿using NHibernate;
using NHibernate.Linq;
using System.Linq;
using Scribble.Services;

namespace Scribble.Repositories
{
    public class TagRepository : ITagRepository
    {
        private readonly ISession session;

        public TagRepository(ISession session)
        {
            this.session = session;
        }

        public Tag GetByTitle(string urlTitle)
        {
            return session
                .Query<Tag>()
                .FirstOrDefault(t => t.UrlTitle == urlTitle);
        }
    }
}